package com.rd.student.jiaji.class3.caiyuxin.Day0728;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Random;
import java.util.Scanner;

public class LineRadomName {
    public static void main(String[] args) throws IOException {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入需要抽出的人数:");
        int n=scanner.nextInt();
        LineRadomName l=new LineRadomName(n);
        lineR();



    }







    static int n;

    public LineRadomName(int n) {
        this.n = n;
    }

    static LinkedList list=new LinkedList();

    public static void lineR() throws IOException {
        BufferedReader reader=new BufferedReader(
                new FileReader("all.txt")
        );
        String line=null;
        while (true) {
            line = reader.readLine();
            if (line == null){break;}
            list.add(line);
        }
        reader.close();

        LinkedList radomlist=new LinkedList();
        for (int i=0;i<list.size();i++){
            radomlist.add(list.get(i));
        }
        Random random=new Random();
        System.out.println("被随机抽到的人员有：");
        for (int j=0;j<n;j++) {

            int i = random.nextInt(radomlist.size());


            System.out.print(radomlist.get(i) + " ");
            radomlist.remove(i);


        }
    }
}
